const BASE_URL = "http://localhost:10000"
const Ws_BASE_URL = "ws://localhost:8085"
/**
 * 封装一个函数，这个函数负责发送请求
 */
export const request = (options:UniApp.RequestOptions)=>{
	return new Promise((resolve,reject)=>{
		uni.request({
			url:BASE_URL + options.url,
			method:options.method || "GET",
			header: { 'Content-Type': 'application/json' },
			data:options.data,
			timeout: 60000, // 设置超时时间为 60 秒
			success:(res)=>{
				resolve(res)
			},
			fail:(error)=>{
				reject(error)
			}
		})
	}) 
};
/**
 * 封装WebSocket连接
 */
export const connectWebSocket = (url: string) => {
	return uni.connectSocket({
		url:Ws_BASE_URL + url,
		success: () => {
			console.log("WebSocket连接请求已发送");
		},
		fail: (error) => {
			console.error("WebSocket连接失败", error);
		},
	});
};





